

#ifndef MYPROJECT_H
#define MYPROJECT_H

#include "stdio.h"
#include "stdbool.h"
/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"
#include "gpio.h"
#include "main.h"
#include "tim.h"
#include "adc.h"
#include "usart.h"

#include "MagneticSensorI2C.h" 
#include "Sensor.h" 
#include "foc_utils.h"
#include "FOCMotor.h"
#include "BLDCmotor.h" 
#include "lowpass_filter.h" 
#include "pid.h"
#include "InlineCurrentSense.h"
#include "CurrentSense.h"

#include "DengFOC.h"

/* USER CODE BEGIN Prototypes */
//#define DENGFOC_CODE 1
#define SIMPLEFOC_CODE 1
//#define STM32_Dev
#ifdef STM32_Dev
#define LED_PIN GPIO_PIN_1
#define LED_GPIO_PORT GPIOA
#else
#define LED_PIN GPIO_PIN_12
#define LED_GPIO_PORT GPIOB
#endif

#define PWM_Period 1440
/******************************************************************************/
#define USART_REC_LEN 256
/******************************************************************************/
extern float target;
extern unsigned char USART_RX_BUF[USART_REC_LEN];
extern unsigned short USART_RX_STA;
void commander_run(void);

void LED_On(void);
void LED_Off(void);
void led_tick();
void GPIO_Key_Init();

#define M1_Enable    HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_SET);          //高电平使能
#define M1_Disable   HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_RESET);        //低电平失能


void enable_module();
void PWM_TEST(void);
//设置使用的编码器为1，不使用的为0
#define M1_AS5600    1   //编码器类型，只能选一


void i2c_bus_scan(void);

float _readADCVoltageInline(uint32_t channel);
uint32_t analogRead(uint32_t channel);
void printff(const char *name, float data);
void printfff(float data);
void Sensor_check();
void Foc_init(float _targe);
void Foc_run(float _targe);
void systick_CountMode(void);//滴答时钟为HCLK/8=72M/8=9Mhz
uint32_t micros(void);
#endif

